package com.ems.init;

import java.io.FileWriter;
import java.io.IOException;

public class TableBean {

	public static void main(String[] args) throws IOException {

		FileWriter writer = new FileWriter("C:\\Users\\15823\\Desktop\\station_collect.sql", true);

		for (int i = 1; i <= 12; i++) {
			int maxday = 0;
			if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) {
				maxday = 31;
			} else if (i == 2) {
				maxday = 29;
			} else {
				maxday = 30;
			}
			for (int j = 1; j <= maxday; j++) {
				String sql = create(i, j);
				writer.write(sql);
			}
		}
		writer.flush();
		writer.close();
	}

	private static String create(int month, int day) {
		StringBuilder sql = new StringBuilder();
		sql.append("CREATE TABLE st_station_quarter_data_").append(month).append("_").append(day);
		sql.append("(");
		sql.append("dataid bigint NOT NULL,");
		sql.append("clientcode VARCHAR ( 100 ) NOT NULL,");
		sql.append("statsyear INT ( 4 ) NOT NULL,");
		sql.append("statsmonth INT ( 2 ) NOT NULL,");
		sql.append("statsday INT ( 2 ) NOT NULL,");
		sql.append("statshour INT ( 2 ) NOT NULL,");
		sql.append("stasminute INT ( 2 ) NOT NULL,");
		sql.append("datamap TEXT,");
		sql.append("recordtime BIGINT ( 11 ),");
		sql.append("PRIMARY KEY ( dataid,clientcode, statsyear, statsmonth, statsday, statshour, stasminute ) ");
		sql.append(");");
		sql.append("\r\n");
		return sql.toString();
	}
}
